<!DOCTYPE html>
<html lang="en">
<head>
    <script src="/static/js/jquery-3.5.1.min.js"></script>
    <link rel="stylesheet" href="../static/css/bootstrap.css">
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #headDiv{
            margin-top: 50px;
        }
        #head {
            margin-left: 400px;

        }
        .form-inline{
            margin-left: 400px;
            margin-top: 10px;
        }
        .buttonDiv{
            margin-left: 400px;
            margin-top: 20px;
        }
        #save{
            margin-right: 120px;
        }
    </style>
</head>
<body>
<div id="headDiv">
    <span id="head">请输入患者信息:</span>
</div>
<form class="form-inline">
    <div class="form-group">
        <label  for="patientInputName">患者姓名</label>
        <input type="email" class="form-control" id="patientInputName">
    </div>
    <div class="form-group">
        <label  for="exampleInputEmail4">科室</label>
        <input type="password" class="form-control" id="exampleInputEmail4" placeholder="白癜风" readonly>
    </div>
    <div class="form-group">
        <label  for="patientInputRecordNo">病历号</label>
        <input type="password" class="form-control" id="patientInputRecordNo"  onchange="getName()">
    </div>
</form>
    <div class="buttonDiv">
        <button type="button" class="btn btn-lg btn-primary"  id="save" onclick="save()">存入</button>
        <button type="button" class="btn btn-lg btn-primary" id="take">取出</button>
    </div>>
<script>
    let getName = function () {
    };
    let save = function () {
        $.ajax({
            type:"get",
            url : "http://127.0.0.1:8080/patientLogin",
            async:true,
            data:{
                name:$("#patientInputName").val(),
                recordNo:$("#patientInputRecordNo").val()
            },
            success : function(data){
                if ("" == data)
                    alert("该病人不存在，请核实后重新输入！")
                else
                    window.location.href = 'http://127.0.0.1:8080/save?name=' + data.name + "&recordNo=" + data.recordNo;
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                console.log(e.status);
                console.log(e.responseText);
            }
        });
    }
</script>
</body>
</html>